import axios from 'axios'
import { Storage } from '../../storage'

const createMyLiveRoom = () => axios.post('/api/live/create', {}, {
    headers: {
        "nothing-token": Storage.get("nothing-token")
    }
}).then(res => res.data)

const getLiveInitInfo = () => axios.get('/api/live/init', {
    headers: {
        "nothing-token": Storage.get("nothing-token")
    }
}).then(res => res.data)

const getMyLiveRoomInfo = () => axios.get('/api/live/info', {
    headers: {
        "nothing-token": Storage.get("nothing-token")
    }
}).then(res => res.data)

const startLive = (form) => axios.put('/api/live/start', form, {
    headers: {
        "nothing-token": Storage.get("nothing-token")
    }
}).then(res => res.data)

const closeLive = (stream) => axios.delete(`/api/live/close/${stream}`).then(res => res.data)


const publishSign = (stream, signInfo) => axios.post(`/api/sign/pub/${stream}`, signInfo).then(res => res.data)


const publishProblem = (stream, problemInfo) => axios.post(`/api/problem/pub/${stream}`, problemInfo).then(res => res.data)

const getMyLiveRecords = () => axios.get('/api/live-record/my', {
    headers: {
        "nothing-token": Storage.get("nothing-token")
    }
}).then(res => res.data)

const getSignRecords = () => axios.get('/api/sign/condition/my', {
    headers: {
        "nothing-token": Storage.get("nothing-token")
    }
}).then(res => res.data)

const getProblemRecords = () => axios.get('/api/problem/condition/my', {
    headers: {
        "nothing-token": Storage.get("nothing-token")
    }
}).then(res => res.data)

export {
    createMyLiveRoom,
    getLiveInitInfo,
    getMyLiveRoomInfo,
    startLive,
    closeLive,
    publishSign,
    publishProblem,
    getMyLiveRecords,
    getSignRecords,
    getProblemRecords
}